 <extend name="Public:base"/>
<block name="leftcolumn">

<div class="panel panel-info">
       <div class="panel-heading">
          <h3 class="panel-title">
             二维码扫描
          </h3>
       </div>
       <div class="panel-body">
              <div class="form-group">
                <button class="btn btn-default" id="scanQRCode0">饲料</button>
                <input type="text" id="id_securityCode_input0" class="form-control"> 
              </div>
              <div class="form-group">
                <button class="btn btn-default" id="scanQRCode1">饲料</button>
                <input type="text"id="id_securityCode_input1" class="form-control">  
              </div> 
              <button id="submit" class="btn btn-primary">提交</button>
       </div>

</div>
</block>
<block name="rightcolumn"> 
  <h1><strong>自动化</strong></h1>
      <ul class="nav nav-pills nav-stacked">
        <li class="active"><a href="{:U('Home/Safe/test', array('name'=>'qrcode'))}">二维码</a></li>
        <li><a href="{:U('Home/Safe/test', array('name'=> 'address'))}">地理位置</a></li>
        <li><a href="{:U('Home/Safe/test', array('name' => 'picture'))}">拍照</a></li>
      </ul>
</block>
<block name="script">

<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
    wx.config({
        debug: false,
        appId: '{$signPackage["appId"]}',
        timestamp: '{$signPackage["timestamp"]}',
        nonceStr: '{$signPackage["nonceStr"]}',
        signature: '{$signPackage["signature"]}',
        jsApiList: [
            'checkJsApi',
            'scanQRCode'
        ]
    });
    wx.ready(function () {

        $("#scanQRCode0").click(function() { 

          wx.scanQRCode({ // 默认为0，扫描结果由微信处理，1则直接返回扫描结果 
                needResult : 1,
                desc : 'scanQRCode desc',
                success : function(res) { //扫码后获取结果参数赋值给Input var
                 url = res.resultStr; //商品条形码，取","后面的
                  if(url.indexOf(",")>=0){ var tempArray = url.split(','); var tempNum = tempArray[1];
                        $("#id_securityCode_input0").val(tempNum);
                    }else{
                        $("#id_securityCode_input0").val(url);
                    }
                }
            });
        });
        $("#scanQRCode1").click(function() { 
          wx.scanQRCode({ // 默认为0，扫描结果由微信处理，1则直接返回扫描结果 
                needResult : 1,
                desc : 'scanQRCode desc',
                success : function(res) { //扫码后获取结果参数赋值给Input var
                 url = res.resultStr; //商品条形码，取","后面的
                  if(url.indexOf(",")>=0){ var tempArray = url.split(','); var tempNum = tempArray[1];
                        $("#id_securityCode_input1").val(tempNum);
                    }else{
                        $("#id_securityCode_input1").val(url);
                    }
                }
            });
        });
     });
</script>
</block>